package com.financialsharing.service.impl;

import com.financialsharing.dao.QuestionAnswerMapper;
import com.financialsharing.pojo.exchange.Answer;
import com.financialsharing.pojo.exchange.Question;
import com.financialsharing.service.QuestionAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName QuestionAnswerImpl
 * @Description TODO
 * @Author lvyongwei
 * @Date 2020-12-21 14:54
 **/
@Service
public class QuestionAnswerServiceImpl implements QuestionAnswerService {

    @Autowired
    private QuestionAnswerMapper questionAnswerMapper;

    /**
     * 查询所有记录
     *
     * @return 返回集合，没有返回空List
     */
    @Override
    public List<Question> listAll(Question question) {
        return questionAnswerMapper.listAll(question);
    }

    /**
     * 根据主键查询
     *
     * @param questionId 主键
     * @return 返回记录，没有返回null
     */
    @Override
    public Question getById(Integer questionId) {
        return questionAnswerMapper.getById(questionId);
    }

    /**
     * 新增，插入所有字段
     *
     * @param tbQuestion 新增的记录
     * @return 返回影响行数
     */
    @Override
    public int insert(Question tbQuestion) {
        return questionAnswerMapper.insert(tbQuestion);
    }

    /**
     * 修改，修改所有字段
     *
     * @param tbQuestion 修改的记录
     * @return 返回影响行数
     */
    @Override
    public int update(Question tbQuestion) {
        return questionAnswerMapper.update(tbQuestion);
    }

    /**
     * 删除记录
     *
     * @param tbQuestion 待删除的记录
     * @return 返回影响行数
     */
    @Override
    public int delete(Question tbQuestion) {
        return questionAnswerMapper.delete(tbQuestion);
    }

    /**
     * 根据问题id获取回答
     *
     * @param answer
     * @return
     */
    @Override
    public List<Answer> getAllAnswer(Answer answer) {
        return questionAnswerMapper.getAllAnswer(answer);
    }

    /**
     * 新增，插入所有字段
     *
     * @param answer 新增的记录
     * @return 返回影响行数
     */
    @Override
    public int insertAnswer(Answer answer) {
        return questionAnswerMapper.insertAnswer(answer);
    }

    /**
     * 修改，修改所有字段
     *
     * @param answer 修改的记录
     * @return 返回影响行数
     */
    @Override
    public int updateAnswer(Answer answer) {
        return questionAnswerMapper.updateAnswer(answer);
    }

    /**
     * 删除记录
     *
     * @param answer 待删除的记录
     * @return 返回影响行数
     */
    @Override
    public int deleteAnswer(Answer answer) {
        return questionAnswerMapper.deleteAnswer(answer);
    }

    /**
     * 获取通过的回复数
     * @param questionId
     * @return
     */
    @Override
    public int getPassAnswer(Integer questionId) {
        return questionAnswerMapper.getPassAnswer(questionId);
    }

    /**
     * 获取总回复数
     * @param questionId
     * @return
     */
    @Override
    public int totalPasswordAnswer(Integer questionId) {
        return questionAnswerMapper.totalPasswordAnswer(questionId);
    }

    /**
     * 做实验时获取的所有
     * @return
     */
    @Override
    public List<Question> getPageQuestion() {
        return questionAnswerMapper.getPageQuestion();
    }

    /**
     * 做实验时获取的所有回复
     * @param questionId
     * @return
     */
    @Override
    public List<Answer> getPageAnswer(Integer questionId , Integer userId) {
        return questionAnswerMapper.getPageAnswer(questionId,userId);
    }
}
